package fields;

import translate.Translate;
import entities.Inventory;
import gstd.Field;
import gstd.Player;

public class Tax extends Field {

	private int tax;
	private double taxRate;

	public Tax(String name, int taxAmount, double taxRate) {
		super(name);
		this.tax = taxAmount;
		this.taxRate = taxRate;
	}

	@Override
	public void landOnField(Player player) {
		Inventory inventory = (Inventory) player.getInventory();
		if (taxRate != 0 && taxRate * inventory.getTotalAssets() < tax)
			inventory.addBalance((int) (-taxRate * inventory.getTotalAssets()));
		else
			inventory.addBalance(-tax);
	}

	public int getTax() {
		return this.tax;
	}

	@Override
	public String toString() {
		System.out.println();
		return Translate.print("pay %d procent or %d", (int) (taxRate * 100.0), tax);
	}
}
